﻿using sscore;

namespace DM4
{
    public partial class DM4
    {
        public void WriteDebugLog(string message, MessageType messageType = MessageType.Info)
        {
            if (_debug)
                _sysLog.WriteLog(message, messageType);

            //DMN_Log
            WriteLog(logType: LogType.System, message: message, messType: messageType);
        }

        public void WriteLog(string message, MessageType messageType = MessageType.Info)
        {
            _sysLog.WriteLog(message, messageType);

            //DMN_Log
            WriteLog(logType: LogType.System, message: message, messType: messageType);
        }

        public string GetSysParam(string prmName)
        {
            if (_prm.Exists(prmName.ToUpper()))
            {
                return _prm.GetStringParam(prmName.ToUpper());
            }
            return "";
        }

        public string GetModuleWorkDir(string sessionId, string ModuleCode)
        {
            if (ModuleExists(ModuleCode))
                return _modules[ModuleCode.ToUpper()].WorkDir;
            else
                return _prm.GetStringParam(DM4Consts.WorkDir.ToUpper());
        }

        public OperationResult WriteLog(LogType logType, string sessId = DM4Consts.SDefaultNULLId, int usrId = DM4Consts.DefaultNULLId, string message = "", MessageType messType = MessageType.Info, string modCode = "")
        {
            LogParameters param = new LogParameters(logType, sessId, messType, modCode, usrId, message);

            return ExecuteDaemonCommand(LogConsts.ModuleCode, LogCommands.InsertLog, param);
        }
    }

}
